Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
array-to-sentence
Advanced tools
Join all elements of an array and create a human-readable string
arrayToSentence(['foo', 'bar', 'baz', 'qux']); //=> 'foo, bar, baz and qux'
npm install array-to-sentence
bower install array-to-sentence
Download the script file directly.
array: Array
of any values
options: Object
Return: String
It joins all elements of an array, and returns a string in the form A, B, ... and X
.
arrayToSentence(['one', 'two', 3]); //=> 'one, two and 3'
arrayToSentence(['one', 'two']); //=> 'one and two'
arrayToSentence(['one']); //=> 'one'
It returns an empty string if the array is empty.
arrayToSentence([]); //=> ''
Type: String
Default: ', '
Set the separator string of each word.
Type: String
Default: ' and '
Set the separator string before the last word.
arrayToSentence(['A', 'B', 'C'], {
separator: '-',
lastSeparator: '-'
}); //=> 'A-B-C'
arrayToSentence(['Earth', 'Wind', 'Fire'], {
lastSeparator: ' & '
}); //=> 'Earth, Wind & Fire'
For designing API, I used .toSentence()
method of underscore.string as reference. Thanks, Esa-Matti Suuronen and the contributors.
Copyright (c) 2014 - 2015 Shinnosuke Watanabe
Licensed under the MIT License.
FAQs
Join all elements of an array and create a human-readable string
The npm package array-to-sentence receives a total of 100,518 weekly downloads. As such, array-to-sentence popularity was classified as popular.
We found that array-to-sentence demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.